import { deepClone } from './clonedeep'

/**
 * @method 筛选当前角色的路由权限菜单
 * @param {角色权限的路由} roleMenu 
 * @param {完整的路由} routeMenu 
 * @returns 
 */
export function getRoleMenu(routeMenu:any,roleMenu:any){
  const routeDeepMenu = deepClone(routeMenu) // 深拷贝前端路由
  const roleRouteArr: any[] = []
  routeDeepMenu?.forEach((element:any) => {
    roleMenu?.forEach((item:any) => {
      if(element?.meta?.title === item.menu_name){
        if(element.children){
          element.children = getRoleMenu(element.children,item.children)
        }
        roleRouteArr.push(element)
      }
    })
  })
  
  return roleRouteArr
}
